package com.songlanyun.modules.exception;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

public enum DistributionException implements IntegerEnum<Integer>
{
    EXTRACT_VALUE_NOT_NORM(30001, "最小分润提现不能大于或等于最大分润提现"),

    ;

    private Integer code;
    private String msg;
    DistributionException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @JsonCreator
    public static DistributionException getByCode(int code) {
        for (DistributionException value : DistributionException.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
